package com.zemb.flxwear.DB;

import android.content.Context;
import android.database.DatabaseErrorHandler;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class FLXDatabase extends SQLiteOpenHelper {

    //血糖表结构
    public static final String CREATE_BLOODSUGAR = "create table Bloodsugar("
            + "id integer primary key autoincrement,"
            + "uid integer,"
            + "bloodSugarLevels double,"
            + "statue text,"
            + "date integer)";
    //总胆表结构
    public static final String CREATE_CHOLESTEROL = "create table Cholesterol("
            + "id integer primary key autoincrement,"
            + "uid integer,"
            + "totalCholesterol double,"
            + "statue text,"
            + "date integer)";
    //尿酸表结构
    public static final String CREATE_URICACID = "create table Uricacid("
            + "id integer primary key autoincrement,"
            + "uid integer,"
            + "uricAcid double,"
            + "statue text,"
            + "date integer)";
    //血酮表结构
    public static final String CREATE_BLOODKETONE = "create table Bloodketone("
            + "id integer primary key autoincrement,"
            + "uid integer,"
            + "bloodKetone double,"
            + "statue text,"
            + "date integer)";


    //以上是血液四项的数据表

    //血压表结构
    public static final String CREATE_BLOODPRESSURE = "create table Bloodpressure("
            + "id integer primary key autoincrement,"
            + "uid integer,"
            + "highPressure double,"
            + "lowPressure double,"
            + "statue text,"
            + "date integer)";

    //血氧表结构
    public static final String CREATE_BLOODOXYGEN = "create table Bloodoxygen("
            + "id integer primary key autoincrement,"
            + "uid integer,"
            + "bloodOxygen double,"
            + "statue text,"
            + "date integer)";
    //心电图表结构
    public static final String CREATE_ECG = "create table ECG("
            + "id integer primary key autoincrement,"
            + "uid integer,"
            + "PR integer,"
            + "other text,"
            + "EGCData text,"
            + "date integer)";
    //用户表结构
    public static final String CREATE_USER = "create table USER("
            + "id integer primary key autoincrement,"
            + "type integer,"
            + "name text,"
            + "phone text,"
            + "sex integer,"
            + "age integer,"
            + "userKey text,"
            + "date integer)";
    //设备表结构
    public static final String CREATE_DEVICE = "create table Device("
        + "id integer primary key autoincrement,"
        + "uid integer,"
        + "type integer,"
        + "name text,"
        + "mac text,"
        + "date integer)";

    public FLXDatabase(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    public FLXDatabase(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version, @Nullable DatabaseErrorHandler errorHandler) {
        super(context, name, factory, version, errorHandler);
    }


    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        //创建表
        sqLiteDatabase.execSQL(CREATE_BLOODSUGAR);
        sqLiteDatabase.execSQL(CREATE_CHOLESTEROL);
        sqLiteDatabase.execSQL(CREATE_URICACID);
        sqLiteDatabase.execSQL(CREATE_BLOODKETONE);
        sqLiteDatabase.execSQL(CREATE_BLOODPRESSURE);
        sqLiteDatabase.execSQL(CREATE_ECG);
        sqLiteDatabase.execSQL(CREATE_BLOODOXYGEN);
        sqLiteDatabase.execSQL(CREATE_USER);
        sqLiteDatabase.execSQL(CREATE_DEVICE);
        

    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }


}
